#!/bin/bash

###############参数配置###################
VIRTUAL_ENVIRONMENT_NAME="nlpservice"
THREAD_NAME='start_xiaok.py'
PYTHON_VERSION="3.6"
LOG_FILE="server.log"

APP_HOME=`cd $(dirname $0)/..;pwd`
LOG_DIR="$APP_HOME"/logs
PID_FILE="${LOG_DIR}"/run.pid
BERT_LOG_FILE='bert_server.log'

if [ ! -d ${LOG_DIR} ]; then
	mkdir ${LOG_DIR}
fi

###############配置文件修改################
bash modify_config_file.sh $1

###############环境初始化################
#bash python_virtual_environment_initialization.sh ${VIRTUAL_ENVIRONMENT_NAME} ${PYTHON_VERSION}

###############激活虚拟环境###############
#source activate ${VIRTUAL_ENVIRONMENT_NAME}

###############结束服务##################
cd "${APP_HOME}"/bin
bash stop.sh ${THREAD_NAME}

################安装模块#################
cd $APP_HOME
#pip --version
#pip install --upgrade pip
pip install -r requirements.txt -i https://pypi.douban.com/simple



################开启服务#################
cd $APP_HOME
nohup python ${THREAD_NAME} >> ${LOG_DIR}/${LOG_FILE} 2>&1 & echo $! > ${PID_FILE}


